﻿using B.S.Medical.Api.Write.Application.Command.Department;
using B.S.Medical.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Medical.Api.Write.Controllers.Department
{
    /// <summary>
    /// 科室管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class DepartmentController : ControllerBase
    {
        private readonly IMediator _mediator;

        public DepartmentController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 添加科室
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> AddDepartment(AddDepartmentCommand request, CancellationToken cancellationToken)
        {
            return await _mediator.Send(request);
        }
        /// <summary>
        /// 修改科室
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> UpdateDepartment(UpdateDepartmentCommand request, CancellationToken cancellationToken)
        {
            return await _mediator.Send(request);
        }
        /// <summary>
        /// 删除科室
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> DeleteDepartment(DeleteDepartmentCommand request, CancellationToken cancellationToken)
        {
            return await _mediator.Send(request);
        }
        /// <summary>
        /// 批量删除科室
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> PLDeleteDepartment(PLDeleteDepartmentCommand request, CancellationToken cancellationToken)
        {
            return await _mediator.Send(request);
        }
    }
}
